

<?php


        
    function insertIntoDatabase($course_name,$course_link,$domain,$type){
        
        require "config.php";
        //echo "course name" .$course."</br>";
        //echo "course link" .$url_link."</br>";

        $con = mysql_connect($db_host,$db_user ,$db_pass);
        
        if (!$con){
            die('Could not connect: ' . mysql_error());
        }
        
        mysql_select_db($db_name, $con);
        $query = " SELECT count(course_name) FROM course WHERE course_name = '".$course_name."' ;";
        $result = mysql_query( $query);
        while($row = mysql_fetch_array($result))
        {
            $course_count = $row['count(course_name)'];
            
        }
        
        $course_count = $course_count +1 ;
        //echo $course_count;
        $sql_insert = "INSERT INTO course VALUES ('".$course_count."','".$course_name."','".$course_link."','".$type."','".$domain."');";
        $result = mysql_query($sql_insert);
        
        
    }

    
    
    
            
?>



